import { createRouter, createWebHistory } from 'vue-router'

import Layout from '@/views/layout/index.vue'
import Login from '@/views/login/index.vue'
import MainPage from '@/views/mainpage/index.vue'
import MyBlogs from '@/views/myblogs/index.vue'
import Personal from '@/views/personal/index.vue'
import ReadBlog from '@/views/readblog/index.vue'
import Addblog from '@/views/writeblog/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home', 
      component: Layout,
      redirect: '/main',
      children: [
        {path: 'main', name: 'main', component: MainPage},
        {path: 'myblogs', name: 'myblogs', component: MyBlogs},
        {path: 'personal', name: 'personal', component: Personal},
        {path: 'readblog/:id' ,name: 'readblog', component: ReadBlog},
        {path: 'addblog' ,name: 'addblog', component: Addblog},
      ]},
    {path: '/login', name: 'login', component: Login},
  ]
})

export default router
